package com.timeDeal.servlet;


import com.timeDeal.bean.PinglunBean;
import com.timeDeal.bean.UserBean;
import com.timeDeal.bean.XuqiufabuBean;
import com.timeDeal.service.PinglunServicce;
import com.timeDeal.service.UserService;
import com.timeDeal.service.XuqiuService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;


/**
 * Created by Administrator on 2016/7/24.
 */

public class TijiaoPIngjiaServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, IOException, IOException {
        String  id =request.getParameter("id")  ;
        XuqiuService xuqiuService = new XuqiuService() ;
        String pingjia  = request.getParameter("wodepingjia") ;
        XuqiufabuBean xuqiufabuBean = xuqiuService.getAxuquById(Integer.valueOf(id)) ;
        UserBean ub = (UserBean)request.getSession().getAttribute("USER");
        if(xuqiufabuBean.getJiafangid()==ub.getYonghuid()){
             xuqiuService.tijiaoPingjia(Integer.valueOf(id),1,pingjia) ;
        }
       else {
            xuqiuService.tijiaoPingjia(Integer.valueOf(id),0,pingjia) ;
        }
            request.getRequestDispatcher("/user/wodejiaoyilishigg.jsp").forward(request,response);

    }
}